package cn.htsyb.synergy.maker.model;

import cn.htsyb.synergy.maker.config.Maker;
import cn.htsyb.synergy.maker.util.HumpUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * 表元数据实体
 *
 * @author lakeside
 * @email hubin_yuan.410@hotmail.com
 * @date 2019-03-26
 */

public class MetaTable {
    /**
     * 表类别
     */
    protected String tableCat;
    /**
     * 表模式
     */
    protected String tableSchem;
    /**
     * 表名称
     */
    protected String tableName;
    /**
     * 表类型。典型的类型是 "TABLE"、"VIEW"、"SYSTEM TABLE"、"GLOBAL TEMPORARY"、"LOCAL TEMPORARY"、"ALIAS" 和 "SYNONYM"。
     */
    protected String tableType;
    /**
     * 表的解释性注释
     */
    protected String remarks;
    /**
     * 类型的类别
     */
    protected String typeCat;
    /**
     * 类型模式
     */
    protected String typeSchem;
    /**
     * 类型名称
     */
    protected String typeName;
    /**
     * 有类型表的指定 "identifier" 列的名称
     */
    protected String selfReferencingColName;
    /**
     * 指定在 SELF_REFERENCING_COL_NAME 中创建值的方式。这些值为 "SYSTEM"、"USER" 和 "DERIVED"
     */
    protected String refGeneration;

    /*filed*/
    /**
     * 主键字段
     */
    protected List<MetaPKColumn> pkColumns = new ArrayList<MetaPKColumn>();
    /**
     * 外键字段
     */
    protected List<MetaFKColumn> fkColumns = new ArrayList<MetaFKColumn>();
    /**
     * 表字典
     */
    protected List<MetaColumn> columns = new ArrayList<MetaColumn>();

    /**
     * 表索引
     */
    protected List<MetaIndex> indexs = new ArrayList<MetaIndex>();

    /*ext*/
    /**
     * 对象大驼峰名称
     */
    protected String pojoName;
    /**
     * 对象小驼峰变量名称
     */
    protected String pojoVarName;
    /**
     * 去除包名后的对象大驼峰名称
     */
    protected String noPackPojoName;
    /**
     * 去除包名后的对象小驼峰变量名称
     */
    protected String noPackPojoVarName;

    public String getTableCat() {
        return tableCat;
    }

    public void setTableCat(String tableCat) {
        this.tableCat = tableCat;
    }

    public String getTableSchem() {
        return tableSchem;
    }

    public void setTableSchem(String tableSchem) {
        this.tableSchem = tableSchem;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;

        String noPackTableName = tableName;
        if (tableName.toLowerCase().startsWith(Maker.getInstance().getCompile().getCurrentPackage().toLowerCase())) {
            noPackTableName = tableName.substring(Maker.getInstance().getCompile().getCurrentPackage().length());
        }
        this.noPackPojoVarName = HumpUtil.convertToSmallHump(noPackTableName, Maker.getInstance().getRegular().getHumpConvertChar());
        this.noPackPojoName = HumpUtil.upperFirstChar(this.noPackPojoVarName);

        this.pojoVarName = HumpUtil.convertToSmallHump(tableName, Maker.getInstance().getRegular().getHumpConvertChar());
        this.pojoName = HumpUtil.upperFirstChar(this.pojoVarName);

    }

    public String getTableType() {
        return tableType;
    }

    public void setTableType(String tableType) {
        this.tableType = tableType;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getTypeCat() {
        return typeCat;
    }

    public void setTypeCat(String typeCat) {
        this.typeCat = typeCat;
    }

    public String getTypeSchem() {
        return typeSchem;
    }

    public void setTypeSchem(String typeSchem) {
        this.typeSchem = typeSchem;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getSelfReferencingColName() {
        return selfReferencingColName;
    }

    public void setSelfReferencingColName(String selfReferencingColName) {
        this.selfReferencingColName = selfReferencingColName;
    }

    public String getRefGeneration() {
        return refGeneration;
    }

    public void setRefGeneration(String refGeneration) {
        this.refGeneration = refGeneration;
    }

    public List<MetaPKColumn> getPkColumns() {
        return pkColumns;
    }

    public void setPkColumns(List<MetaPKColumn> pkColumns) {
        this.pkColumns = pkColumns;
    }

    public List<MetaFKColumn> getFkColumns() {
        return fkColumns;
    }

    public void setFkColumns(List<MetaFKColumn> fkColumns) {
        this.fkColumns = fkColumns;
    }

    public List<MetaColumn> getColumns() {
        return columns;
    }

    public void setColumns(List<MetaColumn> columns) {
        this.columns = columns;
    }

    public String getPojoName() {
        return pojoName;
    }

    public void setPojoName(String pojoName) {
        this.pojoName = pojoName;
    }

    public String getPojoVarName() {
        return pojoVarName;
    }

    public void setPojoVarName(String pojoVarName) {
        this.pojoVarName = pojoVarName;
    }

    public String getNoPackPojoName() {
        return noPackPojoName;
    }

    public void setNoPackPojoName(String noPackPojoName) {
        this.noPackPojoName = noPackPojoName;
    }

    public String getNoPackPojoVarName() {
        return noPackPojoVarName;
    }

    public void setNoPackPojoVarName(String noPackPojoVarName) {
        this.noPackPojoVarName = noPackPojoVarName;
    }

    public List<MetaIndex> getIndexs() {
        return indexs;
    }

    public void setIndexs(List<MetaIndex> indexs) {
        this.indexs = indexs;
    }
}
